package com.atzxh.io.bio.four;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author 小红同学
 * @create 2023-04-11-19:17
 * @description
 */
public class ServerRunnableTarget implements Runnable{

    private Socket socket;

    public ServerRunnableTarget(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            InputStream is = socket.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String msg;
            while ((msg = br.readLine()) != null) {
                System.out.println(msg + Thread.currentThread().getName());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
